// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_FIN_ACCOUNTING_VOUCHER_ITEM
// * CreateDate    : 2012/2/2 10:17:12
// * Creater       : CodeSmith
// * LastChangeDate: 2012/2/2 10:17:12
// * LastChanger   : 2012/2/2 10:17:12
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Fin
{
/// <summary>
    /// FinAccountingVoucherItem
    /// </summary>
    public partial class FinAccountingVoucherItemBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objFinAccountingVoucherItemEntity">Entity</param>
        /// <returns>Entity</returns>
        public static FinAccountingVoucherItemEntity GetFinAccountingVoucherItem(FinAccountingVoucherItemEntity objFinAccountingVoucherItemEntity)
        {
            return DataAccess.SelectSingle<FinAccountingVoucherItemEntity>(objFinAccountingVoucherItemEntity);
        }
        public static FinAccountingVoucherItemEntity GetByID(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return null;
            }
            FinAccountingVoucherItemEntity entity = new FinAccountingVoucherItemEntity();
            entity.ItemId = id;
            return DataAccess.SelectSingle<FinAccountingVoucherItemEntity>(entity);
        }
        public static List<FinAccountingVoucherItemEntity> GetByVoucherID(string coucherId)
        {
            if (string.IsNullOrEmpty(coucherId))
            {
                return null;
            }
            FinAccountingVoucherItemEntity entity = new FinAccountingVoucherItemEntity();
            entity.VoucherId = coucherId;
            return DataAccess.Select<FinAccountingVoucherItemEntity>(entity);
        }
        public static DataTable GetDataTableByVoucherID(string coucherId)
        {
            if (string.IsNullOrEmpty(coucherId))
            {
                return null;
            }
            string sql = @"SELECT AVI.*, FA.ACCOUNTS_NAME, PFA.ACCOUNTS_NAME AS PARENT_ACCOUNTS_NAME
                            FROM FIN_ACCOUNTING_VOUCHER_ITEM AVI
                            LEFT JOIN FIN_ACCOUNTS FA ON FA.ACCOUNTS_CODE = AVI.ACCOUNTS_CODE
                            LEFT JOIN FIN_ACCOUNTS PFA ON PFA.ACCOUNTS_CODE = FA.PARENT_CODE
                            WHERE VOUCHER_ID = '" + coucherId + "'";
            DataSet ds = DataAccess.SelectDataSet(sql);
            if (ds != null && ds.Tables.Count > 0)
            {
                return ds.Tables[0];
            }
            return null;
        }
        #endregion

        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objFinAccountingVoucherItemEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertFinAccountingVoucherItem(FinAccountingVoucherItemEntity objFinAccountingVoucherItemEntity)
        {
            return DataAccess.Insert(objFinAccountingVoucherItemEntity);
        }

        public static bool InsertFinAccountingVoucherItem(List<FinAccountingVoucherItemEntity> objFinAccountingVoucherItemEntityList)
        {
            return DataAccess.Insert(objFinAccountingVoucherItemEntityList);
        }
        #endregion

        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objFinAccountingVoucherItemEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateFinAccountingVoucherItem(FinAccountingVoucherItemEntity objFinAccountingVoucherItemEntity)
        {
            return DataAccess.Update(objFinAccountingVoucherItemEntity);
        }

        public static bool UpdateFinAccountingVoucherItem(List<FinAccountingVoucherItemEntity> objFinAccountingVoucherItemEntityList)
        {
            return DataAccess.Update<FinAccountingVoucherItemEntity>(objFinAccountingVoucherItemEntityList);
        }
        #endregion

        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objFinAccountingVoucherItemEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteFinAccountingVoucherItem(FinAccountingVoucherItemEntity objFinAccountingVoucherItemEntity)
        {
            return DataAccess.Delete(objFinAccountingVoucherItemEntity);
        }

        public static bool DeleteFinAccountingVoucherItem(List<FinAccountingVoucherItemEntity> objFinAccountingVoucherItemEntityList)
        {
            return DataAccess.Delete<FinAccountingVoucherItemEntity>(objFinAccountingVoucherItemEntityList);
        }
        #endregion

        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetFinAccountingVoucherItemAll()
        {
            return DataAccess.SelectAllDataSet<FinAccountingVoucherItemEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<FinAccountingVoucherItemEntity> GetFinAccountingVoucherItemAllList()
        {
            return DataAccess.SelectAll<FinAccountingVoucherItemEntity>();
        }
        #endregion
	}
	
	
}	

